package business_example_service

import (
	"gitee.com/Luna-CY/Golang-Project-Template/internal/interface/dao"

	"gitee.com/Luna-CY/Golang-Project-Template/internal/context"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/errors"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/logger"
	"gitee.com/Luna-CY/Golang-Project-Template/model"
)

func (cls *Example) GetExampleByCondition(ctx context.Context, options ...dao.BusinessExampleOption) (*model.BusinessExample, errors.Error) {
	if 0 == len(options) {
		logger.SugarLogger(logger.WithRequestId(ctx), logger.WithStack()).Errorf("ISE_LE.E_LE.GEBU_ID.152848 options is empty")

		return nil, errors.ErrorServerInternalError("ISE_LE.E_LE.GEBU_ID.173201", "异常的传入参数")
	}

	example, err := cls.example.TakeBusinessExampleByCondition(ctx, options...)
	if nil != err {
		return nil, err.Relation(errors.ErrorServerInternalError("ISE_LE.E_LE.GEBU_ID.223205", "获取数据失败"))
	}

	return example, nil
}
